package com.xy.biz.uc.domain.query;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

@NoArgsConstructor
@AllArgsConstructor
@Builder
@Data
public class UserIdQuery {

    /**
     * 用户Id集合
     */
    private List<Long> userIdList;
    /**
     * 是否查询角色
     */
    private boolean withRole;
    /**
     * 是否查询资源
     */
    private boolean withResource;
    /**
     * 是否查询部门
     */
    private boolean withUserGroup;

    public UserIdQuery addUserId(Long userId) {
        if(userIdList == null) {
            userIdList = new ArrayList<>();
        }
        userIdList.add(userId);
        return this;
    }

    public Long firstUserId() {
        return CollectionUtils.isEmpty(userIdList) ? null : userIdList.get(0);
    }

}
